<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://cdn.bootcss.com/vue/2.5.17-beta.0/vue.js"></script>
<title>申请开店</title>
<style type="text/css">
	body{overflow-y:scroll;}
/*	.sh{display: none;}*/
</style>

</head>
<body>
	
   <% include ../header %>
   
   
   
   
<div class="container" style="margin-top: 1%;">
	
	
	
	<div id="shop_center" style="">
       <div v-for="i in res" style="clear: both;line-height:140px;border: 1px solid #ECECEC; height: 140px;">
       
			<div style="padding: 20px;float: left;line-height: 0;">
				<a :href="'/jd/item?data='+i._id+'&user=<%- user%>'"><img :src="i.information.imga1" class="img" width="100px" height="100px"/></a>
			</div>

			<div style="float: left;margin-left: 20px;width: 150px;">
			    <span>价格:<span class="price" style="color: darkred;display: inline-block;width: 50px;">{{i.information.price}}</span></span>
			    <button type="button" data-toggle="modal" data-target="#myModal" class="btn btn-danger revise_price">修改</button>
			</div>
			
			<div style="line-height:0px;padding-top:40px;padding-left:20px;float: left;position: relative;width: 180px;height: 140px;">
			    <span style="float: left;line-height: 60px;">库存:<span class="number">{{i.information.size_number[0]}}</span></span>
			    <button style="float: right;margin-top: 15px;" type="button" data-toggle="modal" data-target="#myModal" class="btn btn-danger revise_number">修改</button>
			    <div class="ahahah" style="position: absolute;bottom: 25px;left: 16px;">
			    	<img src="" width="25px" :me="i.information.check1"/>
			    	<img src="" width="30px" :me="i.information.check2"/>
			    	<img src="" width="27px" :me="i.information.check3"/>
			    </div>
			</div>
			
			<div style="float: left;margin-left: 40px;width: 150px;">
			    <span>总销量:<span class="sell">{{i.information.sell}}</span></span>
			   
			</div>
			
			<div style="float: left;margin-left: 40px;">
				
			    <span>宝贝ID:<span class="id">{{i._id}}</span></span>
			   
			</div>
			
			<div style="float: right;margin-right: 40px;">
				<button type="button" class="btn btn-dark delete">删除</button>
			</div>
			
	    </div>
	</div>
	
	
	
	
	<div class="modal fade" id="myModal">
  <div class="modal-dialog">
    <div class="modal-content">
 
      <!-- 模态框头部 -->
      <div class="modal-header">
        <h4 class="modal-title">请输入</h4>
        <button type="button" class="close" data-dismiss="modal">&times;</button>
      </div>
 
      <!-- 模态框主体 -->
      <div class="modal-body">
        <input type="number" min="0.01" step="0.01" id="show">
      </div>
 
      <!-- 模态框底部 -->
      <div class="modal-footer">
        <button type="button" class="btn btn-danger" data-dismiss="modal" id="cong">确定</button>
      </div>
 
    </div>
  </div>
</div>
	
	
	
	
	
	
<script type="text/javascript">
	
	
	
//initialise this page
initialise()
	
//revise_price()
//revise_number()
//seller_delete_baby()




function seller_delete_baby () {
	
	$('.delete').on('click',function  () {
		
	 let id=	$(this).parent().prev().find('.id').html()
     
     let data={}
         data.id=id
	     data=JSON.stringify(data)
	    $.ajax({
	    	type:"get",
	    	url:"/jd_index",
	    	async:true,
	    	data:{
	    		'order':'seller_delete_baby',
	    		'data':data
	    	},
	    	success:function  (d) {
	    		
	    			if(d){alert('删除成功')}
	    			location.reload()
	    	},
	    	error:function  (e) {
	    		alert(e)
	    	}
	    });
	    
	})
	
	
	
}

















	
function revise_number () {
		$('.revise_number').on('click',function  () {

		let id=$(this).parent().next().next().find('.id').html()
		let number=$(this).prev().children()
		let data={};
			data.id=id
			
			$('#cong').on('click',function  () {
				let val=$('#show').val()
	            
				data.new_number=val
				data=JSON.stringify(data)
				let ur='/jd_index';    
				ur=encodeURI(ur)
				
				
				$.ajax({
					type:"get",
					url:ur,
					async:true,
					data:{
						'order':'update_number',
						'data':data
					},
					success:function  (d) {
						if(d){number.html(val)}
							
					},
					error:function  (e) {
						alert(e)
					}
				});

			})
	
      })
}	





function  revise_price() {

	$('.revise_price').on('click',function  () {

		let id=$(this).parent().next().next().next().find('.id').html()
		let price=$(this).prev().children()
		let data={};
			data.id=id
			
			$('#cong').on('click',function  () {
				let val=$('#show').val()
	            
				data.new_price=	val
				data=JSON.stringify(data)
				console.log(data)
				let ur='/jd_index';    
				ur=encodeURI(ur)
				
				
				$.ajax({
					type:"get",
					url:ur,
					async:true,
					data:{
						'order':'update_price',
						'data':data
					},
					success:function  (d) {
						if(d){price.html(val)}
							
					},
					error:function  (e) {
						alert(e)
					}
				});

			})
	
      })

}







	
	
	
	
	
	
	
	
	
	
function  initialise() {
		
	
	
		let data={};
			data.user='<%- user%>'
			data=JSON.stringify(data)
			let ur='/jd_index?order=get_release&data='+data;    
			ur=encodeURI(ur)
			
			fetch(ur, {
					method: 'GET',
					})
			.then((res)=>{
							return res.json() 
			})
			.then((res)=>{
						console.log(res)

						
						

                       
						new Vue({
							  el: '#shop_center',
							  data: {
							    res

							  }
							})

						
						$('.ahahah>img').each(function  () {
							
							if($(this).attr('me')=="true"){

								if($(this).index()==0){
									$(this).attr('src','../jd/images/fairy/天猫-七天退货.png')
								}else if($(this).index()==1){
									$(this).attr('src','../jd/images/fairy/正品保证.png')
								}else if($(this).index()==2){
									$(this).attr('src','../jd/images/fairy/service-如实描述.png')
								}else{}
							
							}

						})
						
						
						

						

			})
			.then(()=>{
				revise_price()	
				revise_number()
				seller_delete_baby()
			})
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
}
</script>
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	

   	


   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
<% include ../foot %>
</body>
</html>